


import loading from "./loading.vue";

let instance = null;

export default {

    install(Vue, options) {
        if (!instance) {
            let loadingComponent = Vue.extend(loading);
            instance = new loadingComponent({
                el: document.createElement('div')
            })
            document.body.appendChild(instance.$el);
        }

        instance.isShow = false;


        let customMethods = {
            show() {
                instance.isShow = true;
            },
            hide() {
                let time = setTimeout(function () {
                    instance.isShow = false;
                    clearTimeout(time)
                }, 20)

            }
        }

        if (!Vue.$loading) {
            Vue.$loading = customMethods;
            Vue.prototype.$loading = Vue.$loading;
            // console.log(instance);
        } else {
            console.log('$loading已被占用');
        }
    },
    myLoading() {

    }


}
